package com.itheima.controller;

import com.itheima.entity.Result;
import com.itheima.pojo.Type;
import com.itheima.service.TypeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/type")
@Slf4j
public class TypeController {
    @Autowired
    private TypeService typeService;

    @RequestMapping("/findById")
    public Result findById(Integer id) {
        log.debug("findById param:" + id);
        Type type = typeService.findById(id);
        log.debug("findById result:" + type);
        return new Result(true,"指定查询成功",type);
    }

    @RequestMapping("/findAll")
    public Result findAll() {
        List<Type> typeList = typeService.findAll();
        log.debug("findAll result:" + typeList);
        return new Result(true,"查询成功",typeList);
    }
}
